tests: exercise the per-minute event/query rate limits#153
Conversation
Signed-off-by: Kyle 🐆 <kyle@privkey.io>
|
Warning Review limit reached
Next review available in: 7 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Add
tests/integration_ws_rate_limit.sh(+ a CI step) that drives real traffic to prove the per-IPevents_per_minute/queries_per_minutethrottles actually fire.Why
The connection limit is covered (
integration_ws_idle_reclaim.sh, 429), but the event/query rate limits were untested.handler.zigsends["OK",id,false,"rate-limited: too many events"](:271) and["CLOSED",sub,"rate-limited: too many queries"](:456) and bumpsmetrics.rateLimited()on the throttle path — none of it exercised.How
The rejections are sent over a live connection (a unit test can't see them), so the test drives real traffic and reads the throttle back from the Prometheus counters that increment only on the rate-limit path:
BURST=8valid, uniquely-tagged kind-1 events atLIMIT=3(so a rejection can only be the rate limit, never a bad sig / duplicate / disallowed kind). Assert the first few are accepted, the excessrejected, andwisp_rate_limited_totalrose by the throttled count.wisp_query_rate_limited_totalrose.The token bucket starts full and refills at
LIMIT/60/sec (~negligible over the ~1-2s burst); the assertions allow one refill token of slack (>= BURST-LIMIT-1) so a slow runner can't flake.CI starts a dedicated relay with
WISP_EVENTS_PER_MINUTE=3 WISP_QUERIES_PER_MINUTE=3on port 7787 (mirrors the idle-reclaim step); requires thenozclient the suite already builds.Verification
Ran locally against
zig buildwisp + noz v0.2.1: 4/4 assertions pass, stable across 3 runs. Negative control (relay started with limits100000, throttle effectively off): the test fails (0 throttled) — so it genuinely guards the behavior.Addresses privkeyio/keep-node#11 (the wisp-side rate-limit coverage tracked as keep-node-h3o).